<template>
  <div style="margin-top: 30px">
    <el-row>
      <el-col :span="3"></el-col>
      <el-col :span="18">
        <el-carousel style="margin-bottom: 20px" height="600px">
          <el-carousel-item v-for="item in chart" :key="item.index">
            <!-- <h3 class="small justify-center" text="2xl">{{ item.text }}</h3> -->
            <img :src="item.image" :alt="item.text" />
            <div class="imgtext">
              <lable>{{ item.text }}</lable>
            </div>
          </el-carousel-item>
        </el-carousel>
        <!-- <ChartMap></ChartMap> -->
      </el-col>
      <el-col :span="3"></el-col>
    </el-row>
    <el-row>
      <div class="hometext">
        <el-divider content-position="left">
          <span> 公告中心 </span>
        </el-divider>
        <div class="cardlist">
          <el-timeline>
            <el-timeline-item
              v-for="notice in noticeData"
              :key="notice.id"
              :timestamp="new Date(notice.noticetime).toLocaleString()"
              type="primary"
              hollow
            >
              <el-card @click="toBlog(notice.id)">
                <h6>{{ notice.source }}</h6>
                <el-collapse v-model="activeNames" @change="handleChange">
                  <el-collapse-item :name="notice.id">
                    <template #title>
                      <h5>{{ notice.title }}</h5>
                    </template>
                    <h3>{{ notice.title }}</h3>
                    <div class="content">
                      <p>{{ notice.content }}</p>
                    </div>
                  </el-collapse-item></el-collapse
                >
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </div>
        <!--分页-->
        <div style="padding: 10px 20px; margin-left: 30px; margin-bottom: 20px">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            v-model:currentPage="pageNum"
            :page-sizes="[15, 30, 50]"
            v-model:page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </div>
      </div>
    </el-row>
  </div>
  <el-backtop :right="100" :bottom="100" />
</template>
<script>
export default {
  name: 'Homepage',

  data() {
    return {
      chart: [
        {
          text: '了解接种信息',
          image:
            'https://ts1.cn.mm.bing.net/th/id/R-C.01e70f4cac93ba00731bd5092830f2b2?rik=kXkula%2fPgA4c1A&riu=http%3a%2f%2fimg.lunan.com.cn%2fPublic%2fUploads%2fueditor%2fimage%2fzh-cn%2fother%2f20190425%2f1556179170311115.jpg&ehk=sDIvp81S5IVdaKq2tt8DoDNt1aTuqCBHrh21GT0r3MM%3d&risl=&pid=ImgRaw&r=0',
        },
        {
          text: '疫苗的重要性',
          image:
            'https://ts1.cn.mm.bing.net/th/id/R-C.3ec1213180a3f3a9b8db2f7142ebeb91?rik=h64FCcOYrXRtSw&riu=http%3a%2f%2fimage.nbd.com.cn%2fuploads%2farticles%2fimages%2f1220417%2f___-_____________-_____________________-500985021.jpg&ehk=zaqBCsmETKTwbfgr%2fOkjRhDfzRigeZJV8T987%2fKbMMY%3d&risl=&pid=ImgRaw&r=0',
        },
        {
          text: '疫苗接种系统',
          image: 'https://www.shantou.gov.cn/img/0/113/113240/1858191.jpg',
        },
        {
          text: '预约疫苗接种',
          image:
            'https://ts1.cn.mm.bing.net/th/id/R-C.cf5997ecf94f7d1eafeb1adcaf7afd63?rik=RfQhFQ5jG%2bnQGw&riu=http%3a%2f%2fcustom.huzhou.gov.cn%2fDFS%2fnetwork%2fc27637%2fi2917919%2f16160289777268neiqn.png&ehk=WlpfdXDf7UlhU4vItmLwHMo1HxbZB%2bHorU52zZDGL6c%3d&risl=&pid=ImgRaw&r=0',
        },
      ], //疫苗类型列表
      noticeData: [],
      total: 0, //数据总条数
      pageNum: 1, //当前页
      pageSize: 15, //页大小
    };
  },
  methods: {
    handleSizeChange(val) {
      //页大小改变
      this.pageSize = val;
      this.getnoticeDate();
    },
    handleCurrentChange(val) {
      //当前页改变
      this.pageNum = val;
      this.getnoticeDate();
    },
    //分页查询
    getnoticeDate() {
      this.$http
        .get('/inoculations/notice/pageall', {
          params: {
            pageNum: this.pageNum,
            pageSize: this.pageSize,
          },
        })
        .then((res) => {
          if (res.statusCode == '200') {
            this.total = res.data.total;
            this.noticeData = res.data.records;
          }
        })
        .catch(() => {
          ElMessage.error('数据加载失败,请刷新！');
        });
    },
  },
  created() {
    this.getnoticeDate();
  },
};
</script>
<style scoped>
.el-carousel__item img {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  text-align: center;
  display: table-cell;
  vertical-align: middle;
  position: absolute; /*设为绝对定位*/
  opacity: 0.7; /*设置透明度*/
}
.imgtext {
  height: 40px;
  background-color: #171a1e;
}
.hometext {
  width: 70%;
  margin: 0 auto;
}
.hometext span {
  font-size: 20px;
  font-weight: 600;
}
/* .thebutton {
   padding: 12px;
   font-size: 13px;
   box-shadow: 0 0 0 2px rgba(45,140,240,.2);
} */
.textitem p {
  text-indent: 2em;
  font-size: 16px;
  line-height: 28px;
  display: -webkit-box;
}
.el-card span {
  font-weight: bold;
  font-size: 20px;
}
/* 文字超过三行变为省略号
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    text-overflow: ellipsis;
    overflow: hidden;... */
.el-carousel__item lable {
  margin-left: 30px;
  margin-top: 10px;
  /* bottom: 20px; */
  font-size: 16px;
  font-weight: 600;
  color: ivory;
  position: absolute; /*设为绝对定位*/
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.cardlist {
  width: 100%;
  margin: auto;
  padding: 20px;
}
.cardlist h6 {
  font-weight: 500;
}
.cardlist h5 {
  font-size: 13px;
  line-height: 14px;
}
.content p {
  text-indent: 2em;
  font-size: 13px;
}
/deep/.el-timeline-item__timestamp {
  color: #ffffff;
  line-height: 1;
  font-size: var(--el-font-size-small);
}
/deep/.el-pagination__total {
  margin-left: var(--el-pagination-item-gap);
  font-weight: 400;
  color: #ffffff;
}
/deep/.el-pagination__jump {
  display: flex;
  align-items: center;
  margin-left: var(--el-pagination-item-gap);
  font-weight: 400;
  color: #fff;
}
</style>
